package pt.uma.gap.ast;




public class EvaluateDeclaration {

	public static void evaluate(DeclarationASTInfo declarationASTInfo){
		if(!declarationASTInfo.getDeclarationType().equals(FlowType.UNDEFINED) ){
			return;
		}else if(isPrimitive(declarationASTInfo)){
			declarationASTInfo.setDeclarationType(FlowType.VALUE_FLOW_RULE);
		}else{
			if(declarationASTInfo.getInitializer() != null){
				declarationASTInfo.setDeclarationType(FlowType.ADDRESS_FLOW_RULE);
			}else{
				declarationASTInfo.setDeclarationType(FlowType.NULL_ADDRESS_FLOW_RULE);
			}
		}
	}
	
	private static boolean isPrimitive(DeclarationASTInfo declarationASTInfo) {
		return declarationASTInfo.getVariableDeclarationStatement()
			.getType().isPrimitiveType();

	}
	

}
